define(['common','wx','wx.ajax','wx.tpl','wx.upload','wx.pop','vendor/ueditor/ueditor.config','vendor/ueditor/ueditor.all','vendor/jquery.ztree.all-3.5','vendor/jquery.htmlClean'],function(common,wx){
    var pcPage = {};

    var currentDocument = null;
    var timerSave = 1000;
    var stopsave = 0;
    var startdrag = 0;
    var currenteditor = null;
    var ue = null;
    var wHeight;
    var currentOpenId;
    var pageGlaboData = {
        jscode:'',
        csscode:''
    };

    function init(param){
        wHeight = $('#window_'+wx.stringToJson(param).windowId+'_warp ').find('.window-frame').height();
        var t = new Date().getTime();
        $.when(
            $.ajax('/res/css/pcPage.css?_='+t),
            $.ajax('/res/css/zTreeStyle.css'),
            $.get('/res/js/template/pcPage/pcPageTpl.html?_='+t)
        ).done(function(pageCss,treeCss,pcPageTpl){
            $('<style type="text/css">').append(treeCss[0],pageCss[0]).appendTo('head');
            $('#window-frame-pcPage').html(pcPageTpl[0]);
            wx.sendData('/resource/all','type=4',initTree);
        });
    }


    function initTree(data){
        for (var i = data.result.length - 1; i >= 0; i--) {
            data.result[i].isParent = data.result[i].isParent == '1' ?true:false;
        }
        var setting = {
            view: {
                showLine: true,
                // addHoverDom: addHoverDom,
                // removeHoverDom: removeHoverDom,
                selectedMulti: false
            },
            data: {
                simpleData: {
                    enable:true,
                    idKey: "id",
                    pIdKey: "pId",
                    rootPId: ""
                },
                keep:{
                    leaf:true,
                    parent:true
                }
            },
            edit: {
                enable: true,
                editNameSelectAll: true,
                showRemoveBtn: showRemoveBtn,
                drag: {
                    isCopy:true,
                    autoExpandTrigger: true
                }
            },
            callback: {
                onClick:Onclick,
                onDblClick:OnDdClick,
                onMouseDown:OnMouseDown,
                onRightClick: OnRightClick,
                beforeRemove: beforeRemove,
                // beforeDrag: beforeDrag,
                beforeDrop: beforeDrop,
                onRemove: OnRemove,
                onRename: OnRename
            }
        };
        $('#window-frame-pcPage').append($('#pcPageTpl').html());
        $('#accordion').collapse();
        bindEvent();
        $.fn.zTree.init($('#Js-page-list'), setting,data.result);

        require(['vendor/ueditor/third-party/zeroclipboard/ZeroClipboard'],function(){
            ZeroClipboard.config({swfPath: "/res/js/vendor/ueditor/third-party/zeroclipboard/ZeroClipboard.swf" });
        });
    }


    function OnRightClick(event, treeId, treeNode){
        $('#Js-page-contextmenu').remove();
        var menu = false;
            menu = treeNode && treeNode.isParent;
        
        var zTree = $.fn.zTree.getZTreeObj("Js-page-list");
        zTree.selectNode(treeNode);
        if(menu === false){
            $('body').append(wx.tpl($('#copyTpl').html(),event));
            var client = new ZeroClipboard($('#Js-pcPage-copy'));
            $("body").one("click", function(){
                $('#Js-page-contextmenu').remove();
            });
            client.on( "copy", function (event) {
                event.clipboardData.setData("text/plain",frontWebUrl+'/pc/'+treeNode.id+'.html');
                $('#Js-page-contextmenu').remove();
                $('#window-bar-pcPage').html('地址拷贝成功！');
                setTimeout(function(){$('#window-bar-pcPage').html('');},3000);
            });
        } else{
            $('body').append(wx.tpl($('#contextmenuTpl').html(),event));
            $('#Js-page-addFile').one('click',function(event) {
                createNode(event,0,treeId, treeNode);
                $("body").trigger('click');
            });
            $('#Js-page-addCate').one('click',function(event) {
                createNode(event,1,treeId, treeNode);
                $("body").trigger('click');
            });
            $("body").one("click", function(){
                $('#Js-page-contextmenu').remove();
            });
        }
    }

    function createNode(event,isParent,treeId,treeNode){
        var pId = treeNode?treeNode.id:0;
        wx.sendData('/resource/create','type=4&isParent='+isParent+'&pId='+pId,function(data){
            add(event,data.result.id,isParent);
        });
    }

    function add(event,id,type){
        var zTree = $.fn.zTree.getZTreeObj("Js-page-list"),
        isParent = type,
        nodes = zTree.getSelectedNodes(),
        treeNode = nodes[0];
        if (treeNode) {
            treeNode = zTree.addNodes(treeNode, {id:id, pId:treeNode.id, isParent:isParent, name:"新节点" + id});
        } else {
            treeNode = zTree.addNodes(null, {id:id, pId:0, isParent:isParent, name:"新节点" + id});
        }
        if (treeNode) {
            zTree.editName(treeNode[0]);
        } else {
            alert("叶子节点被锁定，无法增加子节点");
        }
    }

    function beforeDrop(treeId, treeNodes, targetNode, moveType, isCopy) {
        if(targetNode.isParent == false)
            return;
        if(isCopy){
            wx.sendData('resource/copy','sourceId='+treeNodes[0].id+'&pId='+targetNode.id,function(data){
                treeNodes.id = data.result.id;
            });
        } else {
            wx.sendData('resource/move','id='+treeNodes[0].id+'&targetId='+targetNode.id);
        }
        return true;
    }

    function showRemoveBtn(treeId, treeNode) {
        if(treeNode.children)
            return false;
        else
            return true;
    }

    function OnRename(event, treeId, treeNode, isCancel) {
        wx.sendData('/resource/rename','id='+treeNode.id+'&name='+treeNode.name);
    }

    function beforeRemove(treeId, treeNode) {
        return confirm("确认删除 " + treeNode.name + " 吗？");
    }

    function OnRemove(event, treeId, treeNode, isCancel) {
        wx.sendData('/resource/remove','id='+treeNode.id);
    }

    function Onclick(event, treeId, treeNode,clickFlag){
        if(treeNode.isParent === false && clickFlag === 0){
            window.open(hdUrl+'/'+treeNode.id+'.html?t='+(new Date().getTime()));
        }
    }
    function OnDdClick(event, treeId, treeNode){
        if(treeNode && !treeNode.isParent){
            currentOpenId = treeNode.id;
            wx.sendData('/resource/content','id='+currentOpenId,function(data){
                pageGlaboData = data.result.page_info?JSON.parse(data.result.page_info):{};
                if(!pageGlaboData.source){
                    pageGlaboData = {};
                    pageGlaboData.bg = "";
                    pageGlaboData.jscode = "";
                    pageGlaboData.csscode = "";
                    pageGlaboData.source = "";
                }
                $('#headingOne a').trigger('click');
                $('#Js-pcPage-content').attr('data-content',treeNode.name).html(pageGlaboData.source);
                initContainer();
            });
        }
    }
    
    function OnMouseDown(event, treeId, treeNode) {
        if(treeNode){
            var info = '上次修改人：'+treeNode.modify_by+'&nbsp;&nbsp;&nbsp;&nbsp;     修改时间：'+treeNode.modify_time+'&nbsp;&nbsp;&nbsp;&nbsp; | &nbsp;&nbsp;&nbsp;&nbsp;'+'创建人：'+treeNode.create_by+'&nbsp;&nbsp;&nbsp;&nbsp;     创建时间：'+treeNode.create_time;
            $('#window-bar-pcPage').html(info);
        } else {
            $.fn.zTree.getZTreeObj("Js-page-list").cancelSelectedNode();
        }
    }

    function bindEvent(){
        $("#Js-pcPage-content").css("min-height", $('#window-frame-pcPage').height() - 160).css("max-height", wHeight-10);
        $('#Js-pcPage-cate').height($('#window-frame-pcPage').height() - 160);

        $(".sidebar-nav .lyrow").draggable({
            connectToSortable: "#Js-pcPage-content",
            helper: "clone",
            handle: ".drag",
            start: function(e,t) {
                if (!startdrag) stopsave++;
                startdrag = 1;
            },
            drag: function(e, t) {
                t.helper.width('auto');
                t.helper.height('auto');
            },
            stop: function(e, t) {
                $("#Js-pcPage-content .column").sortable({
                    opacity: .35,
                    connectWith: ".column",
                    start: function(e,t) {
                        if (!startdrag) stopsave++;
                        startdrag = 1;
                    },
                    stop: function(e,t) {
                        if(stopsave>0) stopsave--;
                        startdrag = 0;
                    }
                });
                if(stopsave>0) stopsave--;
                startdrag = 0;
            }
        });
        $(".sidebar-nav .box").draggable({
            connectToSortable: ".column",
            helper: "clone",
            handle: ".drag",
            start: function(e,t) {
                if (!startdrag) stopsave++;
                startdrag = 1;
            },
            drag: function(e, t) {
                t.helper.width('auto');
                t.helper.height('auto');
            },
            stop: function() {
                handleJsIds();
                if(stopsave>0) stopsave--;
                startdrag = 0;
            }
        });
        initContainer();

        $('#Js-pcPage-content').on('click','.Js-productId',function(e){
            currenteditor = $(this).parent().parent().find('.view');
            
            var pop = wx.confirm($('#pcPage-inputProductID').html(),{fn:function(){
                var value = $("#pcPage-proId").val();
                var type = $("input[name='productType']:checked").val();
                pop.close();
                getProduction(value,type,function(content){
                    if(currenteditor.find('.products').length == 0)
                        currenteditor.html(content);
                    else
                        currenteditor.append(content);
                });
            }});
        });

        $('#Js-pcPage-content').on('mouseenter','.products', function(){
               $(this).append('<div class="modify">更换商品</div>');
            }).on('mouseleave','.products', function(){
               $(this).find('.modify').remove();
            }).on('click','.products .modify', function(){
                var proContiner = $(this).parent();
                var pop = wx.confirm($('#pcPage-inputProductID').html(),{fn:function(){
                    var value = $("#pcPage-proId").val();
                    var type = $("input[name='productType']:checked").val();
                    pop.close();
                    getProduction(value,type,function(content){
                        proContiner.after(content).remove();
                    });
                }});
            });

        $('#Js-pcPage-content').on("click",".Js-pcPage-edit",function(e) {
            currenteditor = $(this).parent().parent().find('.view');
            var eText = currenteditor.html();
            var pop = wx.pop($('#editorModal').html());
            $('.ui-dialog-container #contenteditor').val(eText);


            UE.delEditor($('.ui-dialog-container #contenteditor')[0]);
            ue = UE.getEditor($('.ui-dialog-container #contenteditor')[0],{
                initialFrameWidth:600,
                initialFrameHeight:200,
                autoFloatEnabled:false,
                scaleEnabled:true,
                toolbars:[[
                    'fullscreen', 'source', '|', 'undo', 'redo', '|',
                    'bold', 'italic', 'underline', 'fontborder', 'strikethrough', 'superscript', 'subscript', 'removeformat', 'formatmatch', 'autotypeset', 'blockquote', 'pasteplain', '|', 'forecolor', 'backcolor', 'insertorderedlist', 'insertunorderedlist', 'selectall', 'cleardoc', '|',
                    'rowspacingtop', 'rowspacingbottom', 'lineheight', '|',
                    'customstyle', 'paragraph', 'fontfamily', 'fontsize', '|',
                    'directionalityltr', 'directionalityrtl', 'indent', '|',
                    'justifyleft', 'justifycenter', 'justifyright', 'justifyjustify', '|', 'touppercase', 'tolowercase', '|',
                    'pclink', 'unlink', '|', 'imagenone', 'imageleft', 'imageright', 'imagecenter', '|',
                    'simpleupload','insertimage','insertcode', 'pagebreak', 'background', '|',
                    'horizontal', 'spechars', 'snapscreen', '|',
                    'inserttable', 'deletetable', 'insertparagraphbeforetable', 'insertrow', 'deleterow', 'insertcol', 'deletecol', 'mergecells', 'mergeright', 'mergedown', 'splittocells', 'splittorows', 'splittocols', 'charts', '|',
                    'preview' ]]
            });

            $(".ui-dialog-container #savecontent").off('click').click(function(e) {
                e.preventDefault();
                currenteditor.html(ue.getContent());
                var bg = $('p[data-background]',currenteditor).data('background');
                if(bg){
                    currenteditor.find('.content').css('background-color',bg.match(/background-color:(.*);/)[1])
                } else {
                    currenteditor.find('.content').css('background-color','rgba(0, 0, 0, 0)');
                }
                pop.close();
            });
        });

        $('#Js-pcPage-content').on("click",".Js-pcPage-background",function(e) {
            var row = $(this).parent().parent().find('.row-fluid');
            var color = row.css('background-color');
            var bg = row.css('background-image');

            if(color){
                color = color.replace(/(?:||rgb|RGB|\(|\))*/g,"").split(",");
                color = ((color[0] << 16) | (color[1] << 8) | color[2]).toString(16);
            } else{
                color = '000000';
            }
            if(bg){
                bg = bg.replace(/[\"\']/g,"");
            }
            var pop = wx.confirm(wx.tpl('#pcPage-bgSelector',{img:bg,color:color}),{title:'背景',fn:function(){
                var img = $("#pcPage-preview").css('background-image');

                row.css('background-color',$("#pcPage-colorBG").val());
                row.css('background-image',img);
                pop.close();
            }});
            wx.upload($('#Js-uploadIcon'));
        });
        // $('#Js-pcPage-content').on("click","[data-target=#editorModal]",function(e) {
        //     e.preventDefault();
        //     currenteditor = $(this).parent().parent().find('.view');
        //     var eText = currenteditor.html();
        //     contenthandle.setData(eText);
        // });

        $("[data-target=#downloadModal]").click(function(e) {
            e.preventDefault();
            downloadLayoutSrc();
        });
        $("[data-target=#shareModal]").click(function(e) {
            e.preventDefault();
            handleSaveLayout();
        });
        $("#download").click(function() {
            downloadLayout();
            return false
        });
        $("#downloadhtml").click(function() {
            downloadHtmlLayout();
            return false
        });
        $("#edit").click(function() {
            $("body").removeClass("devpreview sourcepreview");
            $("body").addClass("pcPage-container");
            removeMenuClasses();
            $(this).addClass("active");
            return false
        });
        $("#devpreview").click(function() {
            $("body").removeClass("pcPage-container sourcepreview");
            $("body").addClass("devpreview");
            removeMenuClasses();
            $(this).addClass("active");
            return false
        });
        $("#sourcepreview").click(function() {
            $("body").removeClass("pcPage-container");
            $("body").addClass("devpreview sourcepreview");
            removeMenuClasses();
            $(this).addClass("active");
            return false
        });
        $("#fluidPage").click(function(e) {
            e.preventDefault();
            changeStructure("container", "container-fluid");
            $("#fixedPage").removeClass("active");
            $(this).addClass("active");
            downloadLayoutSrc()
        });
        $("#fixedPage").click(function(e) {
            e.preventDefault();
            changeStructure("container-fluid", "container");
            $("#fluidPage").removeClass("active");
            $(this).addClass("active");
            downloadLayoutSrc()
        });
        $(".nav-header").click(function() {
            $(".sidebar-nav .boxes, .sidebar-nav .rows").hide();
            $(this).next().slideDown()
        });
        $('#undo').click(function(){
            stopsave++;
            if (undoLayout()) initContainer();
            stopsave--;
        });
        $('#redo').click(function(){
            stopsave++;
            if (redoLayout()) initContainer();
            stopsave--;
        });
        $('#Js-pageScript').click(function(data){
            var content = $('#pcPage-script').html().replace(/&amp;/g,'&').replace(/&gt;/g,'>').replace(/&lt;/g,'<');
            var editor;
            var pop = wx.confirm(wx.tpl(content,pageGlaboData),{title:'代码',fn:function(){
                pageGlaboData.jscode = editor.getValue().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/"/g,'\"');
            }});
            common.createAce('Js-pcPage-code',function(e){
                editor = e;
            });
        });

        $('#Js-pageCss').click(function(data){
            var content = $('#pcPage-css').html().replace(/&amp;/g,'&').replace(/&gt;/g,'>').replace(/&lt;/g,'<');
            var editor;
            var pop = wx.confirm(wx.tpl(content,pageGlaboData),{title:'样式',fn:function(){
                pageGlaboData.csscode = editor.getValue().replace(/&lt;/g,'<').replace(/&gt;/g,'>').replace(/"/g,'\"');
            }});
            common.createAce('Js-pcPage-css',function(e){
                editor = e;
            });
        });

        $('#Js-pageBG').click(function(data){
            var pop = wx.confirm(wx.tpl('#pcPage-bgSelector',pageGlaboData),{title:'颜色选择',fn:function(){
                var value = $("#pcPage-colorBG").val();
                pageGlaboData.bg = value;
                $('#Js-pcPage-content').css('background-color',value);
                pop.close();
            }});
        });
        $('#Js-pageSave').click(function(data){
            pageGlaboData.jscode = pageGlaboData.jscode.replace(/"/g,'\"').replace(/'/g,'\'');
            pageGlaboData.source=$('#Js-pcPage-content').html().replace(/"/g,'\"').replace(/'/g,'\'');
            $.load();
            wx.sendData('/resource/save-pageinfo',{data:{'id':currentOpenId,'info':JSON.stringify(pageGlaboData)}},function(data){
                wx.sendData('/resource/save-content',{data:{'moduleName':'webPage','id':currentOpenId,'content':downloadLayoutSrc()}},function(data){
                    if(data.status)
                        $.succ('保持成功');
                    else
                        $.fail('保持失败');
                });
            });
        });
        removeElm();
        gridSystemGenerator();
    }

    function getProduction(ids,type,callback){
        var proId = [];
        ids = ids.split(';');
        for(var i =0;i<ids.length;i++){
            if(ids[i].trim().length == 0)
                continue;
            proId.push('{"goodsID":"'+ids[i].trim()+'","cartMethod":"0","callType":0}');
        }
        $.ajax({url:'http://sapi.tootoo.cn/goods/MainServlet?method=getGoodsInfo&req_fmt_type=jsonp&req_str={"channelType":"1","scope":"11101","goodsList":['+proId.join(',')+'],"shippingAddress":3,"withGoodsDesc":"0","withExtendsInfo":"0","withSaleCatInfo":"0","withSavInfo":"0","withPicInfo":"1","withSpecialInfo":"0","withPriceInfo":"1","withStockInfo":"0","withShippingInfo":"0","withSkuInfo":"0"}',dataType:'jsonp',success:function(data){
            if(data.Result.Header.resultID != 0 || data.Result.Data.goodsInfo.length==0){
                alert('商品ID不合法');
                return;
            }
            data.Result.Data.goodsInfo.type=type;
            var goods = data.Result.Data.goodsInfo;
            for(var i=0;i<goods.length;i++){
                if(type == '1'){
                    if(goods[i].skuInfo.isPromotion=='1'&&goods[i].skuInfo.promotionPrice!=0){
                        goods[i].price = goods[i].skuInfo.promotionPrice;
                    }else{
                        goods[i].price = goods[i].skuInfo.theOriginalPrice;
                    }
                } else {
                  for(var j=0;j<goods[i].priceInfo.vipPrice.length;j++){
                    if(goods[i].priceInfo.vipPrice[j].buyerLevelId == 54){
                        goods[i].price = goods[i].priceInfo.vipPrice[j].goodsPrice;
                    }
                  }
                }
            }

            callback(wx.tpl($("#pcPage-production").html().replace(/&amp;/g,'&').replace(/&gt;/g,'>').replace(/&lt;/g,'<'),{goods:data.Result.Data.goodsInfo}));
        }});
    }

    function handleJsIds() {
        handleModalIds();
        handleAccordionIds();
        handleCarouselIds();
        handleTabsIds()
    }

    function handleAccordionIds() {
        var e = $("#Js-pcPage-content #myAccordion");
        var t = randomNumber();
        var n = "accordion-" + t;
        var r;
        e.attr("id", n);
        e.find(".accordion-group").each(function(e, t) {
            r = "accordion-element-" + randomNumber();
            $(t).find(".accordion-toggle").each(function(e, t) {
                $(t).attr("data-parent", "#" + n);
                $(t).attr("href", "#" + r)
            });
            $(t).find(".accordion-body").each(function(e, t) {
                $(t).attr("id", r)
            })
        })
    }
    function handleCarouselIds() {
        var e = $("#Js-pcPage-content #myCarousel");
        var t = randomNumber();
        var n = "carousel-" + t;
        e.attr("id", n);
        e.find(".carousel-indicators li").each(function(e, t) {
            $(t).attr("data-target", "#" + n)
        });
        e.find(".left").attr("href", "#" + n);
        e.find(".right").attr("href", "#" + n)
    }
    function handleModalIds() {
        var e = $("#Js-pcPage-content #myModalLink");
        var t = randomNumber();
        var n = "modal-container-" + t;
        var r = "modal-" + t;
        e.attr("id", r);
        e.attr("href", "#" + n);
        e.next().attr("id", n)
    }
    function handleTabsIds() {
        var e = $("#Js-pcPage-content #myTabs");
        var t = randomNumber();
        var n = "tabs-" + t;
        e.attr("id", n);
        e.find(".tab-pane").each(function(e, t) {
            var n = $(t).attr("id");
            var r = "panel-" + randomNumber();
            $(t).attr("id", r);
            $(t).parent().parent().find("a[href=#" + n + "]").attr("href", "#" + r)
        })
    }
    function randomNumber() {
        return randomFromInterval(1, 1e6)
    }
    function randomFromInterval(e, t) {
        return Math.floor(Math.random() * (t - e + 1) + e)
    }

    function gridSystemGenerator() {
        $(".lyrow .preview input").bind("keyup", function() {
            var e = 0;
            var t = "";
            var n = $(this).val().split(" ", 12);
            $.each(n, function(n, r) {
                e = e + parseInt(r);
                t += '<div class="span' + r + ' column"></div>'
            });
            if (e == 12 || e == '通屏') {
                $(this).parent().next().children().html(t);
                $(this).parent().prev().show()
            } else {
                $(this).parent().prev().hide()
            }
        })
    }

    function configurationElm(e, t) {
        $("#Js-pcPage-content").delegate(".configuration > a", "click", function(e) {
            e.preventDefault();
            var t = $(this).parent().next().next().children();
            $(this).toggleClass("active");
            t.toggleClass($(this).attr("rel"))
        });
        $("#Js-pcPage-content").delegate(".configuration .dropdown-menu a", "click", function(e) {
            e.preventDefault();
            var t = $(this).parent().parent();
            var n = t.parent().parent().next().next().children();
            t.find("li").removeClass("active");
            $(this).parent().addClass("active");
            var r = "";
            t.find("a").each(function() {
                r += $(this).attr("rel") + " "
            });
            t.parent().removeClass("open");
            n.removeClass(r);
            n.addClass($(this).attr("rel"))
        })
    }
    function removeElm() {
        $("#Js-pcPage-content").delegate(".remove", "click", function(e) {
            e.preventDefault();
            $(this).parent().remove();
        })
    }

    function initContainer(){
        $("#Js-pcPage-content, #Js-pcPage-content .column").sortable({
            connectWith: ".column",
            opacity: .35,
            handle: ".drag",
            start: function(e,t) {
                if (!startdrag) stopsave++;
                startdrag = 1;
            },
            stop: function(e,t) {
                if(stopsave>0) stopsave--;
                startdrag = 0;
            }
        });
        configurationElm();
    }

    function cleanHtml(e) {
        $(e).parent().append($(e).children().html())
    }

    function downloadLayoutSrc() {
        var e = "";
        $("#Js-html").html($("#Js-pcPage-content").html());

        var t = $("#Js-html").children();
        t.removeAttr('style');
        t.find(".preview, .configuration, .drag, .remove").remove();
        t.find(".lyrow").addClass("removeClean");
        t.find(".box-element").addClass("removeClean");
        t.find(".lyrow .lyrow .lyrow .lyrow .lyrow .removeClean").each(function() {
            cleanHtml(this)
        });
        t.find(".lyrow .lyrow .lyrow .lyrow .removeClean").each(function() {
            cleanHtml(this)
        });
        t.find(".lyrow .lyrow .lyrow .removeClean").each(function() {
            cleanHtml(this)
        });
        t.find(".lyrow .lyrow .removeClean").each(function() {
            cleanHtml(this)
        });
        t.find(".lyrow .removeClean").each(function() {
            cleanHtml(this)
        });
        t.find(".removeClean").each(function() {
            cleanHtml(this)
        });

        t.find(".removeClean").remove();
        $("#Js-html .column").removeClass("ui-sortable");
        $("#Js-html .row-fluid").removeClass("clearfix").children().removeClass("column");
        if ($("#Js-html .container").length > 0) {
            changeStructure("row-fluid", "row")
        }

        formatSrc = $.htmlClean($("#Js-html").html(), {
            format: true,
            allowedAttributes: [
                ["id"],
                ["class"],
                ["style"],
                ["data-toggle"],
                ["data-target"],
                ["data-parent"],
                ["role"],
                ["data-dismiss"],
                ["aria-labelledby"],
                ["aria-hidden"],
                ["data-slide-to"],
                ["data-slide"],
                ["skuid"],
                ["maxnum"],
                ["minnum"],
                ["buyfrom"],
                ["stationid"],
                ["promotetype"],
                ["amount"],
                ["flyimg"]
            ]
        });
        return formatSrc;
    }


	pcPage.init = init;
    return pcPage;
});